/****************************************************
          File Name:8-2.cpp
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Sat 20 Dec 2014 07:01:53 PM CST
*****************************************************/

#include<iostream>
using namespace std;

struct candybar
{
    char *brand;
    float weight;
    int caluroes;
};

void show(const candybar & st)
{
    cout << "brand: " << st.brand << endl;
    cout << "weight: " << st.weight << endl;
    cout << "caluroes: " << st.caluroes << endl;
}

void fill(candybar & st, const char *br, float wei, int cal)
{
	int i;
	for(int i=0;br[i]!='\0';) i++;
	st.brand = new char[i];
	for(int j=0;j<i;j++) st.brand[i] = br[i];
	
    st.weight = wei;
    st.caluroes = cal;
}

int main()
{
    candybar bar;

    fill(bar, "Millennium Munch", 2.85, 350);  // clang will show warning
    show(bar);
	delete [] bar.brand;
    return 0;
}
